<template>
  <div id="ConstructionContract">
    <van-tabs v-model="active">
      <!-- ||rowData?.OPTYPE != '60' -->
      <van-tab title="线上签合同" v-if="rowData.SQFS != 36 && rowData?.OPTYPE != 60">
        <div class="iframeWrap">
          <!-- <iframe :src="iframeUrl" frameborder="0" width="100%" height="100%"></iframe> -->
          <HtPage></HtPage>
        </div>
        <div class="footer">
          <van-button  size="small" style="width: 20vw;" type="info" @click="save">签字</van-button>
          <van-button size="small"  style="width: 20vw;" type="info" @click="handlesubup">提交</van-button>
          <!-- <van-button
              v-show="this.$store.state.isGJ"
              size="small"
              type="info"
              @click="goBack1"
              >退回</van-butto1n
            > -->
        </div>
      </van-tab>
      <!-- //旧版  -->
      <van-tab v-if="$store.state.VERSIONNUMBER != 1" title="线下合同上传">
        <div class="top1">
          <img style="width: 80%; margin: 0 auto" src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/ZLJ/xian.png" />
          <p>
            <span :class="showMoble ? '' : 'PADD1'" style="width: 22%; display: inline-block; text-align: center">申请</span>
            <span style="width: 26%; display: inline-block; text-align: center">选图选工匠</span>
            <span style="width: 25%; display: inline-block; text-align: center">签订合同</span>
            <span :class="showMoble ? '' : 'PADD2'" style="width: 21%; display: inline-block; text-align: center">四到场</span>
          </p>
        </div>
        <!-- <div class="linStyle" v-if="ISShowPDf">
          <span><span style="color: #ff0000;margin-left: -13px;">*</span>合同文件(pdf)</span>
          <el-upload ref="upload" :http-request="uploadFile6" multiple style="float: right" :max-count="1"
            class="upload-demo" action="https://jsonplaceholder.typicode.com/posts/" :on-success="handleAvatarSuccess"
            :before-upload="beforeAvatarUpload1">
            <p v-if="file[3].name" class="avatar" @click="openUrl(file[3].url)">
              {{ file[3].name }}
            </p>
            <el-button v-else size="mini" type="primary">点击上传</el-button>
          </el-upload>
        </div> -->
        <upLoad
          id="upLoad4"
          :ISDelete="isreadonly"
          :rowData="rowData"
          :readonly="isreadonly"
          :FJData="file1"
          @getFileServerUpload1="getFileID1"
          @getFileServerUpload="getFileID"
          @delectFile="delectFiless"
          :SHITUID="'98bcf528966e48ce896a8b3fd02d45d5'"
          :UpLoadID="'7a3fc061c866434b8475d3775c9ddcea'" />
        <div style="display: flex; justify-content: center; align-items: center; color: black">
          <van-field :required="true" :readonly="isreadonly" v-model="XXHTZD.i_xxht_jzmj" type="number" label="建筑面积(㎡)" placeholder="请填写建筑面积(㎡)" />
        </div>
        <div style="display: flex; justify-content: center; align-items: center; color: black">
          <van-field :required="true" :readonly="isreadonly" v-model="XXHTZD.i_xxht_fwcg" type="number" label="房屋层高(m)" placeholder="请填写房屋层高" />
        </div>
        <div v-if="rowData?.OPTYPE == '60'">
          <!--  -->
          <!-- <van-field v-model="XXHTZD.i_xxht_xmfzr" label="项目负责人" placeholder="请填写项目负责人" /> -->
          <select-picker
            :bitian="true"
            :isTime="false"
            :ISrequired="isreadonly"
            :labels="'项目负责人'"
            :values="'nickname'"
            :DICID="'idCard'"
            :columns="projectData"
            :selectValue="i_xxht_xmfzr"
            @getMessage="setValue"
            placeholder="请选择项目负责人"></select-picker>
        </div>
        <div v-if="rowData?.OPTYPE == '60'">
          <select-picker
            :bitian="true"
            :isTime="false"
            :ISrequired="isreadonly"
            :labels="'施工负责人'"
            :values="'nickname'"
            :DICID="'idCard'"
            :columns="projectDataXM"
            :selectValue="i_xxht_sgfzr"
            @getMessage="setValue1"
            placeholder="请选择施工负责人"></select-picker>
          <!-- <van-field v-model="XXHTZD.i_xxht_sgfzr" label="施工负责人" placeholder="请填写施工负责人" /> -->
        </div>
        <div style="display: flex; justify-content: center; align-items: center; color: black">
          <van-field :required="true" :readonly="isreadonly" v-model="XXHTZD.i_jine"  label="合同金额(万元)" placeholder="请填写合同金额" />
        </div>
        <div style="display: flex; justify-content: center; align-items: center; color: black">
          <van-field
            :required="true"
            :readonly="!isreadonly"
            clickable
            name="datetimePicker"
            v-model="XXHTZD.i_qdsj"
            label="签订日期"
            placeholder="请选择"
            @click="!isreadonly ? (showPickerq = true) : false" />
          <van-popup v-model="showPickerq" position="bottom" get-container="#popup">
            <van-datetime-picker v-model="currentDate" type="date" title="选择年月日" @cancel="showPickerq = false" @confirm="onConfirm" />
          </van-popup>
        </div>
        <div style="display: flex; justify-content: center; align-items: center; color: black">
          <van-field
            :required="true"
            :readonly="!isreadonly"
            clickable
            name="datetimePicker"
            v-model="XXHTZD.XXHT_GQKSSJ"
            label="合同工期开始时间"
            placeholder="选择年月日"
            @click="!isreadonly ? (showPickerq1 = true) : false" />
          <van-popup v-model="showPickerq1" position="bottom" get-container="#popup">
            <van-datetime-picker v-model="currentDate1" type="date" title="选择年月日" @cancel="showPickerq1 = false" @confirm="onConfirm1" />
          </van-popup>
        </div>
        <div style="display: flex; justify-content: center; align-items: center; color: black">
          <van-field
            :required="true"
            :readonly="!isreadonly"
            clickable
            name="datetimePicker"
            v-model="XXHTZD.XXHT_GQJSSJ"
            label="合同工期结束时间"
            placeholder="选择年月日"
            @click="!isreadonly ? (showPickerq2 = true) : false" />
          <van-popup v-model="showPickerq2" position="bottom" get-container="#popup">
            <van-datetime-picker v-model="currentDate2" type="date" title="选择年月日" @cancel="showPickerq2 = false" @confirm="onConfirm2" />
          </van-popup>
        </div>
        <!-- <div class="linStyle1" v-if="ISShowPDf2">
          <p>合同照片</p>
          <van-uploader ref="upload" class="elUp" :after-read="uploadFile7" :before-delete="delectFile"
            v-model="fileListID1" multiple />
        </div> -->
        <div class="HT_footer">
          <!-- <van-button style="width: 24vw" @click="deleteFileAll" type="info">清空文件</van-button> -->
          <van-button v-if="fileListID.length == 0" style="width: 90vw" @click="getUpadatefun" type="info">提交</van-button>
          <van-button v-else style="width: 90vw" @click="getUpadatefun" type="info">确认无误</van-button>
        </div>
      </van-tab>
      <!-- //新版 -->
      <van-tab v-else title="线下合同上传">
        <OfflineContract  :rowData="rowData"/>
      </van-tab>
    </van-tabs>
    <van-popup v-model="shoulm">
      <div class="con_box">
        <h3>{{ text.title }}</h3>
        <p>{{ text.message }}</p>
        <p>
          确认倒计时：<span style="font-size: 22px">{{ num1 }}S</span>
        </p>
        <div class="btnv">
          <span @click="handleClose()" v-if="text.btn.cancelText">
            {{ text.btn.cancelText }}
          </span>
          <span @click="handleOk()" v-if="text.btn.okText">
            {{ text.btn.okText }}
          </span>
        </div>
      </div>
    </van-popup>
    <van-popup v-model="shoulm1">
      <div class="con_box">
        <h3>{{ text1.title }}</h3>
        <p>{{ text1.message }}</p>
        <p>
          确认倒计时：<span style="font-size: 22px">{{ num1 }}S</span>
        </p>
        <div class="btnv">
          <span @click="handleClose1()" v-if="text1.btn.cancelText">
            {{ text1.btn.cancelText }}
          </span>
          <span @click="handleOk1()" v-if="text1.btn.okText">
            {{ text1.btn.okText }}
          </span>
        </div>
      </div>
    </van-popup>
  </div>
</template>
<script>
import HtPage from '../ZLJ/htPage.vue'
import OfflineContract from '../newZlb/OfflineContract.vue'
import { GJDBFunction2 } from '@/utils/queryData'
import { addDate, GSA_Search,GSA_Add } from '@/common/commonApi'
import {
  signGJ,
  signNH,
  QuerySignCallback,
  HXSignForPlatForm,
  QuerySignCallback1,
  updateDataView,
  dataTransFile,
  FileServerProxy,
  houseApplyUpdate,
  houseRemoldUnitBuildPersonSG,
  houseRemoldUnitProjectPersonXM,
  houseRemoldUnitBuildPersonXM
} from '../../utils/api'
import { v4 as uuidv4 } from 'uuid'
import upLoad from '@/utils/upLoad'
import selectPicker from '@/utils/selectPicker'
import { isArray, result } from 'lodash'
// import { it } from 'node:test'
export default {
  name: 'ConstructionContract',
  data() {
    return {
      iframeUrl: '',
      isOfflineContract:true,
      isreadonly: false,
      projectDataXM: [],
      showPickerq: false,
      showPickerq1: false,
      showPickerq2: false,
      currentDate: new Date(),
      currentDate1: new Date(),
      currentDate2: new Date(),
      rowData: '',
      projectData: [],
      i_xxht_sgfzr: '',
      i_xxht_xmfzr: '',
      HTJE: '',
      file1: [
        {
          title: '合同文件',
          groupGuid: '2774cbb5-1854-4a0a-afaf-bee2e8f83cab',
          FileName: [],
          fileList: []
        }
      ],
      //项目负责人
      isXM: false,
      isSG: false,
      showMoble: false,
      ISShowPDf2: true,
      ISShowPDf: true,
      shoulm1: false,
      XXHTZD: {
        i_qdsj: null,
        i_jine: null,
        i_xxht_jzmj: null,
        i_xxht_fwcg: null,
        i_xxht_xmfzr: null,
        i_xxht_sgfzr: null,
        XXHT_GQJSSJ:null,
        XXHT_GQKSSJ:null
      },
      CBRS: '',
      QDRQ: '',
      num1: 3,
      baseUrl: window.g.BaseURL,
      // baseUrl:'https://nfzjszlb.jst.zj.gov.cn/',
      shoulm: false,
      active: 0,
      fileListID: [],
      fileListID1: [],
      fileListID2: [],
      Canshu: 0,
      timer: null,
      text: {
        title: '温馨提示',
        message: '请用户确认是否已经签署合同?',
        btn: {
          okText: '已签署',
          cancelText: '未签署'
        }
      },
      text1: {
        title: '温馨提示',
        message: '请用户确认是否退回给工匠重新签合同?',
        btn: {
          okText: '确认',
          cancelText: '取消'
        }
      },
      file: [
        {
          name: '',
          url: ''
        },
        {
          name: '',
          url: ''
        },
        {
          name: '',
          url: ''
        },
        {
          name: '',
          url: ''
        }
      ]
    }
  },
  components: {
    HtPage,
    upLoad,
    selectPicker,
    OfflineContract
  },
  props: {
    SGXKData: ''
  },
  methods: {
    //根据update_qsdj_and_jine_by_rowGuid这个存储过程获取建筑面积或者房屋层高项目负责人等信息
    async getHTXXData() {
      let data = {
        i_row_guid: this.rowData.ROW_GUID,
        i_qdsj: null,
        i_jine: null,
        i_xxht_jzmj: null,
        i_xxht_fwcg: null,
        i_xxht_xmfzr: null,
        i_xxht_sgfzr: null,
        i_XXHT_GQKSSJ: null,
        i_XXHT_GQJSSJ: null,
        i_type: '2',
      }
      debugger
      const JSONSend = await GJDBFunction2('update_qsdj_and_jine_by_rowGuid', [data])
      if (JSONSend?.length > 0) {
        this.XXHTZD.i_qdsj = JSONSend[0].QDSJ
        this.XXHTZD.i_jine = JSONSend[0].JINE
        this.XXHTZD.i_xxht_jzmj = JSONSend[0].XXHT_JZMJ
        this.XXHTZD.i_xxht_fwcg = JSONSend[0].XXHT_FWCG
        this.XXHTZD.i_xxht_xmfzr = JSONSend[0].XXHT_XMFZR
        this.XXHTZD.XXHT_GQJSSJ = JSONSend[0].XXHT_GQJSSJ
        this.XXHTZD.XXHT_GQKSSJ = JSONSend[0].XXHT_GQKSSJ
        this.XXHTZD.i_xxht_xmfzr = JSONSend[0].XXHT_XMFZR
        this.i_xxht_xmfzr = JSONSend[0].XXHT_XMFZR
        this.XXHTZD.i_xxht_sgfzr = JSONSend[0].XXHT_SGFZR
        this.i_xxht_sgfzr = JSONSend[0].XXHT_SGFZR
        this.getProgectData()
        // this.isreadonly = true
      }
    },
    setValue(name, value) {
      console.log(name, value, 'wseeddd')
      //请求
      this.XXHTZD.i_xxht_xmfzr = name
      this.getProgectData1(value)
    },
    setValue1(name, value) {
      console.log(name, value)
      //请求
      this.XXHTZD.i_xxht_sgfzr = name
    },
    //根据当前的角色确认合同更新对应的字段  农户、代办人：HTBHQDZT   工匠：HTQDZT  项目负责人：F_JZQYXMFZR 施工负责人：F_JZQYSGFZR
    async getUpadateQUE() {
      console.log(this.rowData, 'this.rowData')
      let params = {
        uscc: this.rowData.TYSH,
        idCard: window.localStorage.getItem('DanDianid')
      }
      const res = await houseRemoldUnitBuildPersonXM(params)
      debugger
      //如果是1 为项目负责人 如果为2 施工负责人 如果为1,2
      console.log(this.isSG, 'this.isSG')
      if (res.data.data[0] == 1) {
        this.isXM = true
      } else if (res.data.data[0] == 2) {
        this.isSG = true
        if (this.rowData.HTBHQDZT == null && this.rowData.HTQDZT == null && this.rowData.F_JZQYXMFZR == null && this.rowData.F_JZQYSGFZR == null) {
          this.isreadonly = true
          this.$confirm({
            title: '提示',
            message: '施工负责人不支持上传合同',
            btn: {
              okText: '确定',
              cancelText: '取消'
            }
          })
            .then(() => {
              // do something
            })
            .catch(() => {
              console.log('no')
            })
        }
      } else if ((res.data.data[0] == 1, 2)) {
        this.isSG = true
        this.isXM = true
      } else {
        this.isSG = false
      }
      console.log(this.isSG, 'this.isSG')
    },
    //获取项目负责人接口
    async getProgectData() {
      let params = {
        isDelete: 0,
        uscc: this.rowData.TYSH
      }
      const res = await houseRemoldUnitProjectPersonXM(params)
      this.projectData = res.data.data
      if (this.XXHTZD.i_xxht_xmfzr) {
        this.projectData.forEach((item) => {
          if (item.idCard == this.XXHTZD.i_xxht_xmfzr) {
            this.i_xxht_xmfzr = item.nickname
          }
        })
        this.getProgectData1(this.XXHTZD.i_xxht_xmfzr)
      }
    },
    //获取施工负责人接口
    async getProgectData1(data) {
      let params = {
        isDelete: 0,
        uscc: this.rowData.TYSH,
        projectPersonIdcard: data
      }
      const res = await houseRemoldUnitBuildPersonSG(params)
      this.projectDataXM = res.data.data
      if (this.XXHTZD.i_xxht_sgfzr) {
        this.projectDataXM.forEach((item) => {
          console.log(item.idCard, this.XXHTZD.i_xxht_sgfzr, 'knini')
          if (item.idCard == this.XXHTZD.i_xxht_sgfzr) {
            this.i_xxht_sgfzr = item.nickname
          }
        })
      }
    },
    delectFiless(data) {
      if (data) {
        this.fileListID = ''
      }
    },
    //goBack
    handleClose() {
      this.shoulm = false
      clearInterval(this.timer)
      this.timer = null
      this.num1 = 3
    },
    handlesubup() {
      this.shoulm = true
      let me = this
      me.timer = setInterval(function () {
        me.num1--
        if (me.num1 < 1) {
          clearInterval(me.timer)
          me.timer = null
          me.num1 = 0
        }
        console.log(me.num1)
      }, 1000)
    },
    //回显
    getFileID1(data) {
      console.log(data, 'data')
      this.fileListID = data.fileList.length > 0 ? data.fileList : data.FileName
      console.log(this.fileListID)
    },
    //上传之后
    async getFileID(data) {
      //需要用存储过程把id存下来
      let params = [
        {
          i_fileName: data[0].FILENAME,
          i_to_row_guid: this.rowData.ROW_GUID,
          i_fileGuid: data[0].FILEGUID,
          i_type: 1
        }
      ]
      const res = await GJDBFunction2('update_fileGuid_by_fileName_and_toRowGuid', params)
      //回显上次存储的FILEGUID
      // let params = [{
      //   "i_fileName": null,
      //   "i_to_row_guid": this.rowData.ROW_GUID,
      //   "i_fileGuid": null,
      // }]
      // const res = await GJDBFunction2('update_fileGuid_by_fileName_and_toRowGuid', params)
      // data.fileList[0].FILEGUID = res.i_fileGuid

      this.fileListID = data
      console.log(this.fileListID, 'djhfbue')
    },
    handleOk(data) {
      //倒计时
      if (this.num1 == 0) {
        this.next1()
        this.shoulm = false
        this.num1 == 3
      } else if (this.num1 > 0) {
        this.$toast.fail('请稍后！')
      }
      // this.handleButton();
    },
    //竣工时间
    onConfirm(val) {
      this.showPickerq = false
      this.XXHTZD.i_qdsj = this.formatGetDate(val)
    },
    onConfirm1(val) {
      this.showPickerq1 = false
      this.XXHTZD.XXHT_GQKSSJ = this.formatGetDate(val)
    },
    onConfirm2(val) {
      this.showPickerq2 = false
      this.XXHTZD.XXHT_GQJSSJ = this.formatGetDate(val)
    },
    formatGetDate(val) {
      let year = val.getFullYear()
      let month = val.getMonth() + 1
      let day = val.getDate()
      let hour = val.getHours()
      let minute = val.getMinutes()
      if (month >= 1 && month <= 9) {
        month = `0${month}`
      }
      if (day >= 1 && day <= 9) {
        day = `0${day}`
      }
      if (hour >= 0 && hour <= 9) {
        hour = `0${hour}`
      }
      if (minute >= 0 && minute <= 9) {
        minute = `0${minute}`
      }
      let data = `${year}-${month}-${day}`
      return data
    },
    handleClose1() {
      this.shoulm1 = false
      clearInterval(this.timer)
      this.timer = null
      this.num1 = 3
    },
    goBack1() {
      this.shoulm1 = true
      let me = this
      me.timer = setInterval(function () {
        me.num1--
        if (me.num1 < 1) {
          clearInterval(me.timer)
          me.timer = null
          me.num1 = 0
        }
        console.log(me.num1)
      }, 1000)
    },
    handleOk1() {
      if (this.num1 == 0) {
        this.goBack()
        this.shoulm1 = false
        this.num1 == 3
      } else if (this.num1 > 0) {
        this.$toast.fail('请稍后！')
      }
    },
    delectFile: async function (file) {
      this.$toast.success('删除成功!')
    },
    goBack: async function () {
      var formData2 = [
        {
          PKID: JSON.parse(window.localStorage.getItem('rowData')).PKID,
          row_guid: JSON.parse(window.localStorage.getItem('rowData')).ROW_GUID,
          HTQDZT: ''
        }
      ]
      let parms = {
        dataGuid: 'b68a5f59-7527-4cb8-bd8a-9b5451bb2d50',
        strParams: JSON.stringify(formData2)
      }
      let paramsendMEssage = {
        accessCode: '77ad6c1591e54d4fbc45ecc90374a2a2',
        cityCode: window.localStorage.getItem('isGJM') == 'true' ? window.localStorage.getItem('citycode') : window.localStorage.getItem('citycodeChange'),
        params: parms
      }
      const res1 = await QuerySignCallback(paramsendMEssage)
      if (JSON.parse(res1.data.data).Success == true) {
        this.$toast.success('回退成功')
      } else {
        this.$toast.fail('回退失败')
      }
    },
    //清空并删除文件
    async deleteFileAll() {
      console.log(this.fileListID)
      if (this.ISShowPDf && this.fileListID.length > 0) {
        this.$refs.upload.uploadFiles = []
        let params = {
          accessCode: 'ce9b691634de4ebca68dc5bb638d07f4',
          cityCode: window.localStorage.getItem('isGJM') == 'true' ? window.localStorage.getItem('citycode') : window.localStorage.getItem('citycodeChange'),
          params: {
            fileGuid: this.fileListID[0].FILEGUID || '',
            token: window.localStorage.getItem('token')
          }
        }
        const res = await FileServerProxy(params)
        let data = JSON.parse(res.data.data).Success
        if (data) {
          this.$toast.success('删除成功!')
        }
      } else {
        this.fileListID = []
        this.fileListID1 = []
        this.fileListID2 = []
        this.$toast.success('删除成功!')
      }
      this.ISShowPDf2 = true
      this.ISShowPDf = true
      // this.$toast.success('删除成功')
    },
    goToNext: async function () {
      //根据当前的角色确认合同更新对应的字段  农户、代办人：HTBHQDZT   工匠：HTQDZT  项目负责人：F_JZQYXMFZR 施工负责人：F_JZQYSGFZR
      var formData2 = [
        {
          PKID: JSON.parse(window.localStorage.getItem('rowData')).PKID,
          row_guid: JSON.parse(window.localStorage.getItem('rowData')).ROW_GUID,
          // HTQDZT: '1',
          // HTBHQDZT: '1',
          F_ISSAVEHT: '1'
        }
      ]
      debugger
      if (this.$store.state.isGJ && window.localStorage.getItem('userType') != 'QY') {
        debugger
        formData2[0].HTBHQDZT = '1'
      } else if (!this.$store.state.isGJ && window.localStorage.getItem('userType') != 'QY') {
        formData2[0].HTQDZT = '1'
      } else if (window.localStorage.getItem('userType') == 'QY' && this.isXM) {
        //需要判断当前人是项目负责人还是施工负责人
        formData2[0].F_JZQYXMFZR = '1'
      } else if (window.localStorage.getItem('userType') == 'QY' && this.isSG) {
        formData2[0].F_JZQYSGFZR = '1'
      } else if (window.localStorage.getItem('userType') == 'QY' && this.isSG && this.isXM) {
        formData2[0].F_JZQYSGFZR = '1'
        formData2[0].F_JZQYXMFZR = '1'
      }
      let parms = {
        dataGuid: 'b68a5f59-7527-4cb8-bd8a-9b5451bb2d50',
        strParams: JSON.stringify(formData2)
      }
      let paramsendMEssage = {
        accessCode: '77ad6c1591e54d4fbc45ecc90374a2a2',
        cityCode: window.localStorage.getItem('isGJM') == 'true' ? window.localStorage.getItem('citycode') : window.localStorage.getItem('citycodeChange'),
        params: parms
      }
      const res1 = await QuerySignCallback(paramsendMEssage)
      if (JSON.parse(res1.data.data).Success == true) {
        this.$toast.success('合同已签订')
        // this.getUpadatefun1()
        if(JSON.parse(window.sessionStorage.getItem('fileData'))?.S){
          debugger
          this.$emit('handleactive2',2)
        }else{
          this.$router.push({
          path: '/ZLJIndex'
        })
        }

      } else {
        this.$toast.fail('合同签订失败')
      }
    },
    // 点击“点击上传”弹出文件选择框并执行保存接口
    savePdf: async function () {
      if (this.Canshu == 1) {
        //新增
        var accessCode = '00b87f486f8b11ecacdb8c8caa46b312'
      } else {
        //修改
        var accessCode = '77ad6c1591e54d4fbc45ecc90374a2a2'
      }
      let par = []
      // if (this.ISShowPDf) {
      par = [
        {
          zwfwhtid: this.fileListID[0].FILEGUID,
          zwfwhtname: this.fileListID[0].FILENAME
        }
      ]
      // } else {
      //   debugger
      //   console.log(this.fileListID2)
      //   let newArr = []
      //   this.fileListID2.forEach((item) => {
      //     newArr.push(item[0].FILEGUID)
      //   })

      //   par.push({
      //     htscpt: newArr.join(','),
      //   })
      // }
      let params = {
        accessCode: accessCode,
        cityCode: window.localStorage.getItem('isGJM') == 'true' ? window.localStorage.getItem('citycode') : window.localStorage.getItem('citycodeChange'),
        params: {
          dataGuid: 'e83485a7-0e53-40b9-b881-cf184792be89',
          strParams: JSON.stringify(par),
          token: window.localStorage.getItem('token')
        }
      }
      const res = await QuerySignCallback(params)
      if (JSON.parse(res.data.data).Success) {
        //需要更新id
        let parmes = {
          contractId: '', //合同ID
          serialNumber: JSON.parse(window.localStorage.getItem('rowData')).LSH, //统一编号
          rowGuid: JSON.parse(window.localStorage.getItem('rowData')).ROW_GUID, //业务标识
          isOnline: 0 //是否在线签合同
        }
        // if (!this.ISShowPDf) {
        //   let newArr = []
        //   this.fileListID2.forEach((item) => {
        //     newArr.push(item[0].FILEGUID)
        //   })
        //   parmes.contractId = newArr.join(',')
        // } else {
        parmes.contractId = this.fileListID[0].FILEGUID
        // }
        const res2 = await houseApplyUpdate(parmes)
        if (res2.data.data) {
          this.$toast.success('保存成功')
          this.goToNext()
        } else {
          this.$toast.fail('保存失败')
        }
      } else {
        this.$toast.fail('保存失败')
      }
    },
    //获取线下签合同数据
    async getData1111(){
      let data = [{ "field": "ROW_GUID", "value": this.rowData.ROW_GUID }]
      const res = await GSA_Search(this.$store.state.VERSIONNUMBER == 1?'89d035c0-5095-45f2-bece-fa7eecc5c732':'931c475d-c6f3-41c0-8aef-28e20922db97', data)
      console.log(res,'edkifnuierobfguijorefguijrbnfuji')
    },
    getUpadatefun: async function () {
      debugger
      //判断当前是工匠还是企业签合同的件
      //如果是工匠则隐藏项目负责人和施工负责人
      //如果是企业则展示项目负责人和施工负责人并且请求项目负责人接口
      //需要判断当前是否已经上传过文件
      //根据当前的用户角色更新不同的id
      //要判断
      console.log(this.fileListID)
      console.log(this.isSG)
      if (this.rowData.HTBHQDZT == null && this.rowData.HTQDZT == null && this.rowData.F_JZQYXMFZR == null && this.rowData.F_JZQYSGFZR == null && this.isSG && !this.isXM) {
        this.$toast.fail('请联系农户或者项目负责人上传合同')
        return false
      }
      if (this.fileListID.length == 0) {
        this.$toast.fail('请先上传合同')
        return
      }
      let index = 0
      if (this.rowData?.OPTYPE == '60') {
        console.log(this.XXHTZD, 'this.XXHTZD')
        for (let i in this.XXHTZD) {
          if (!this.XXHTZD[i]) {
            index += 1
          }
        }
        if (index > 0) {
          this.$toast.fail('请填写必填项')
          return
        }
      } else {
        if (!this.XXHTZD.i_qdsj || !this.XXHTZD.i_jine || !this.XXHTZD.i_xxht_jzmj || !this.XXHTZD.i_xxht_fwcg) {
          this.$toast.fail('请填写必填项')
          return
        }
      }
      //调用存储过程保存签订时间和金额

      let data = [
        {
          i_row_guid: this.rowData.ROW_GUID,
          i_qdsj: this.XXHTZD.i_qdsj,
          i_jine: this.XXHTZD.i_jine,
          i_xxht_jzmj: this.XXHTZD.i_xxht_jzmj,
          i_xxht_fwcg: this.XXHTZD.i_xxht_fwcg,
          i_xxht_xmfzr: this.XXHTZD.i_xxht_xmfzr,
          i_xxht_sgfzr: this.XXHTZD.i_xxht_sgfzr,
          i_XXHT_GQKSSJ: this.XXHTZD.XXHT_GQKSSJ,
          i_XXHT_GQJSSJ: this.XXHTZD.XXHT_GQJSSJ,
          i_type: '1'
        }
      ]
      const JSONSend = await GJDBFunction2('update_qsdj_and_jine_by_rowGuid', data)
      if (JSONSend.length == 0) {
        this.$toast.fail('更新失败 请重试')
        return
      }
      let paerssend = {
        procName: 'up_query',
        dtParams: JSON.stringify([{ I_USERID: "'" + this.rowData.ROW_GUID + "'", I_TYPE: 6 }]),
        token: window.localStorage.getItem('token')
      }
      let paramsendMEssage = {
        accessCode: '69db6bece3a7480592e2ec753d1e335e',
        cityCode: window.localStorage.getItem('isGJM') == 'true' ? window.localStorage.getItem('citycode') : window.localStorage.getItem('citycodeChange'),
        params: paerssend
      }
      const reqwmsg = await QuerySignCallback(paramsendMEssage)
      if (JSON.parse(reqwmsg.data.data).Data[0]) {
        if (JSON.parse(reqwmsg.data.data).Data[0].SEARCH == 0) {
          this.Canshu == 1
        } else {
          this.Canshu == 0
        }
        this.savePdf()
      }
    },
    //上传成功后清空之前所填写的合同内容执行存储过程1
    getUpadatefun1: async function () {
      let paerssend = {
        procName: 'up_query',
        dtParams: JSON.stringify([{ I_USERID: this.rowData.ROW_GUID, I_TYPE: 5 }]),
        token: window.localStorage.getItem('token')
      }
      let paramsendMEssage = {
        accessCode: '69db6bece3a7480592e2ec753d1e335e',
        cityCode: window.localStorage.getItem('isGJM') == 'true' ? window.localStorage.getItem('citycode') : window.localStorage.getItem('citycodeChange'),
        params: paerssend
      }
      const reqwmsg = await QuerySignCallback(paramsendMEssage)
    },
    uploadFile6(file) {
      this.ISShowPDf2 = false
      this.uploadFileAll1(file)
    },
    uploadFile7(file) {
      this.ISShowPDf = false
      if (Array.isArray(file)) {
        file.forEach((item, index) => {
          console.log(item)
          this.uploadFileAll11(item.file)
        })
      } else {
        this.uploadFileAll11(file.file)
      }
    },
    handleAvatarSuccess() {},
    beforeAvatarUpload() {},
    //上传照片
    uploadFileAll11: async function (file) {
      console.log(this.fileListID1, 'djj')
      let me = this
      let data = {
        toRowGuid: this.rowData.ROW_GUID,
        groupGuid: '2774cbb5-1854-4a0a-afaf-bee2e8f83cab',
        token: window.localStorage.getItem('token')
      }
      let formData = new FormData()
      formData.append('file', file)
      formData.append('accessCode', '7a3fc061c866434b8475d3775c9ddcea')
      formData.append('cityCode', window.localStorage.getItem('isGJM') == 'true' ? window.localStorage.getItem('citycode') : window.localStorage.getItem('citycodeChange'))
      // formData.append("token", window.localStorage.getItem("token"));
      formData.append('paramStr', JSON.stringify(data))
      const res = await dataTransFile(formData)
      let data1 = JSON.parse(res.data.data).FileList
      if (data1) {
        this.$toast.success('上传成功')
        debugger
        // this.fileListID1.push(data1)
        this.fileListID2.push(data1)
        console.log(data1)
        // this.getUpadatefun()
      } else {
        this.$toast.fail('上传失败')
      }
    },
    //上传的pdf
    uploadFileAll1: async function (file) {
      let me = this
      let data = {
        toRowGuid: this.rowData.ROW_GUID,
        groupGuid: '2774cbb5-1854-4a0a-afaf-bee2e8f83cab',
        token: window.localStorage.getItem('token')
      }
      let formData = new FormData()
      formData.append('file', file.file)
      formData.append('accessCode', '7a3fc061c866434b8475d3775c9ddcea')
      formData.append('cityCode', window.localStorage.getItem('isGJM') == 'true' ? window.localStorage.getItem('citycode') : window.localStorage.getItem('citycodeChange'))
      // formData.append("token", window.localStorage.getItem("token"));
      formData.append('paramStr', JSON.stringify(data))
      const res = await dataTransFile(formData)
      let data1 = JSON.parse(res.data.data).FileList
      if (data1) {
        this.$toast.success('上传成功')
        this.fileListID = data1
        // this.getUpadatefun()
      } else {
        this.$toast.fail('上传失败')
      }
    },
    // 签字
    save: async function () {
      //先查询合同表有没有数据，有就签字，没有提示
      let params = {
        dataGuid: 'e83485a7-0e53-40b9-b881-cf184792be89',
        searchObject: JSON.stringify([
          {
            field: 'TO_ROW_GUID',
            value: this.rowData.ROW_GUID,
            link: 'OR',
            operator: '='
          }
        ]),
        token: window.localStorage.getItem('token')
      }
      let params3 = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b',
        cityCode: window.localStorage.getItem('isGJM') == 'true' ? window.localStorage.getItem('citycode') : window.localStorage.getItem('citycodeChange'),
        params: params
      }
      var res = await QuerySignCallback(params3)
      var dataf = '' //存签过合同的ZWFWHTID
      var dataw = '' //还没签过合同 使用当前行
      debugger
      if (this.rowData && this.rowData.F_NEIWANGID) {
        var str = this.rowData.F_NEIWANGID.toString().split('#').join(':')
        // var str = 'http://10.145.12.79:28800'
      } else {
        var str = 'http://10.145.12.79:28800'
      }
      if (eval('(' + res.data.data + ')').Data.length > 0) {
        if (eval('(' + res.data.data + ')').Data[0].ZWFWHTID) {
          //有人已签合同
          dataf = eval('(' + res.data.data + ')').Data[0].ZWFWHTID
        } else {
          //有人未签合同
          dataw = eval('(' + res.data.data + ')').Data[0].ROW_GUID
        }
      }
      if (eval('(' + res.data.data + ')').Data.length > 0) {
        let userInfo = window.localStorage.getItem('userName')
        if (!this.$store.state.isGJ) {
          //生成uuid
          // let uuid = uuidv4();
          // this.$store.commit("getUUID1", uuid);
          // window.localStorage.setItem("UUID1", uuid);
          let params2 = {
            callbackUrl: this.baseUrl, //可以写死
            callbackParam: 'fileGuid=bed4afda-d7c8-45a2-ac58-068ee5e3f832', //可以写死
            fileUrl: 'https://zjseal.zjzwfw.gov.cn/api/tyyzpt/sign/downloadSignFile/b456eac2da7711ecba2e6c92bfce1812.pdf',
            isPerson: '1', //可以写死
            pdfFileFlag: this.rowData.ROW_GUID,
            personDTO: {
              handSignWay: '0',
              isFreeSign: '0',
              username: window.localStorage.getItem('DanDianName'),
              mobile: window.localStorage.getItem('DanDianPhone'),
              idnum: window.localStorage.getItem('DanDianid'),
              idType: '1',
              signPositionDTO: {
                keyword: '承包人(签字或者盖章)',
                llx: '110',
                lly: '0'
              }
            }
          }
          this.CBRS = eval('(' + res.data.data + ')').Data[0].CBR
          if (dataf) {
            //已经签过合同了
            // params2.signTime = '0'
            params2.fileUrl = 'https://zjseal.zjzwfw.gov.cn/api/tyyzpt/sign/downloadSignFile/' + dataf + '.pdf'
          } else {
            params2.signTime = '1'
            params2.fileUrl = str + '/PrintServer/api/PreviewWordRpt?groupGuid=%7B21D9D29E-CB7B-4015-8510-1426351C5C88%7D&toRowGuid=' + dataw + '&dataGuid=e83485a7-0e53-40b9-b881-cf184792be89'
            // params2.fileUrl = "https://nfzjszlb.jst.zj.gov.cn/file/group1/test/signTest.pdf"
          }
          const res1 = await HXSignForPlatForm(params2)
          var ZWFWHTID = JSON.parse(res1.data.data)
          var formdata = eval('(' + res.data.data + ')')
          if (res1.data.data) {
            //id值需要存一份  方便农户签订合同
            formdata.Data[0].ZWFWHTID = ZWFWHTID.data
            var formData2 = [formdata.Data[0]]
            let parms = {
              dataGuid: 'e83485a7-0e53-40b9-b881-cf184792be89',
              strParams: JSON.stringify(formData2)
            }
            let paramsendMEssage = {
              accessCode: '77ad6c1591e54d4fbc45ecc90374a2a2',
              cityCode: window.localStorage.getItem('isGJM') == 'true' ? window.localStorage.getItem('citycode') : window.localStorage.getItem('citycodeChange'),
              params: parms
            }
            const res2 = await QuerySignCallback(paramsendMEssage)
            if (ZWJSBridge && JSON.parse(res1.data.data).data) {
              ZWJSBridge.openLink({
                url: 'https://zjseal.zjzwfw.gov.cn/api/tyyzpt/sign/doViewDoc?id=' + JSON.parse(res1.data.data).data
              })
                .then((res) => {
                  //
                  console.log(res)
                })
                .catch((err) => {
                  window.open('https://zjseal.zjzwfw.gov.cn/api/tyyzpt/sign/doViewDoc?id=' + JSON.parse(res1.data.data).data)
                })
            } else {
              this.$toast.fail(JSON.parse(res1.data.data).errorMsg)
            }
          } else {
            this.$toast.fail(res1.data.message)
          }
        } else {
          //农户不需要判断eval("(" + res.data.data + ")").Data[0].ZWFWHTID
          // if (eval("(" + res.data.data + ")").Data[0].ZWFWHTID) {
          //生成uuid
          let uuid = uuidv4()
          this.$store.commit('getUUID1', uuid)
          window.localStorage.setItem('UUID1', uuid)
          // 如果eval("(" + res.data.data + ")").Data[0].ZWFWHTID有值或者工匠
          if (this.rowData.DBRXM != '' && this.rowData.DBRXM != null) {
            if (window.localStorage.getItem('DanDianName') == this.rowData.DBRXM || window.localStorage.getItem('DanDianPhone') == this.rowData.DBRSJH) {
              var params1 = {
                callbackUrl: this.baseUrl,
                callbackParam: 'fileGuid=bed4afda-d7c8-45a2-ac58-068ee5e3f832',
                fileUrl: 'https://zjseal.zjzwfw.gov.cn/api/tyyzpt/sign/downloadSignFile/' + dataf + '.pdf',
                isPerson: '1',
                // signTime:"1",
                pdfFileFlag: this.rowData.ROW_GUID,
                personDTO: {
                  handSignWay: '0',
                  isFreeSign: '0',
                  username: window.localStorage.getItem('DanDianName'),
                  mobile: window.localStorage.getItem('DanDianPhone'),
                  idnum: window.localStorage.getItem('DanDianid'),
                  idType: '1',
                  signPositionDTO: {
                    keyword: '发包人(签字或者盖章)',
                    llx: '110',
                    lly: '30'
                  }
                }
              }
            } else {
              var params1 = {
                callbackUrl: this.baseUrl,
                callbackParam: 'fileGuid=bed4afda-d7c8-45a2-ac58-068ee5e3f832',
                fileUrl: 'https://zjseal.zjzwfw.gov.cn/api/tyyzpt/sign/downloadSignFile/' + dataf + '.pdf',
                isPerson: '1',
                // signTime:"1",
                pdfFileFlag: this.rowData.ROW_GUID,
                personDTO: {
                  handSignWay: '0',
                  isFreeSign: '0',
                  username: window.localStorage.getItem('DanDianName'),
                  mobile: window.localStorage.getItem('DanDianPhone'),
                  idnum: window.localStorage.getItem('DanDianid'),
                  idType: '1',
                  signPositionDTO: {
                    keyword: '发包人(签字或者盖章)',
                    llx: '110',
                    lly: '30'
                  }
                }
              }
            }
          } else {
            var params1 = {
              callbackUrl: this.baseUrl,
              callbackParam: 'fileGuid=bed4afda-d7c8-45a2-ac58-068ee5e3f832',
              fileUrl: 'https://zjseal.zjzwfw.gov.cn/api/tyyzpt/sign/downloadSignFile/' + dataf + '.pdf',
              isPerson: '1',
              pdfFileFlag: this.rowData.ROW_GUID,
              personDTO: {
                handSignWay: '0',
                isFreeSign: '0',
                username: window.localStorage.getItem('DanDianName'),
                mobile: window.localStorage.getItem('DanDianPhone'),
                idnum: window.localStorage.getItem('DanDianid'),
                idType: '1',
                signPositionDTO: {
                  keyword: '发包人(签字或者盖章)',
                  llx: '110',
                  lly: '30'
                }
              }
            }
          }
          if (dataf) {
            //已经签过合同了
            // params1.signTime = '0'
            params1.fileUrl = 'https://zjseal.zjzwfw.gov.cn/api/tyyzpt/sign/downloadSignFile/' + dataf + '.pdf'
          } else {
            params1.signTime = '1'
            params1.fileUrl = str + '/PrintServer/api/PreviewWordRpt?groupGuid=%7B21D9D29E-CB7B-4015-8510-1426351C5C88%7D&toRowGuid=' + dataw + '&dataGuid=e83485a7-0e53-40b9-b881-cf184792be89'
            // params1.fileUrl = "https://nfzjszlb.jst.zj.gov.cn/file/group1/test/signTest.pdf"
          }
          console.log(this.rowData, 'dfvgnjewfgiu')
          //签合同（已签订或者未签订）
          const res1 = await HXSignForPlatForm(params1)
          //保存签订合同的信息
          if (res1.data.data && JSON.parse(res1.data.data).data) {
            // eval("(" + res.data.data + ")").Data[0].ZWFWHTID = JSON.parse(
            //   res1.data.data
            // ).data;
            var formData2 = [eval('(' + res.data.data + ')').Data[0]]
            formData2[0].ZWFWHTID = JSON.parse(res1.data.data).data
            console.log(formData2, ';sfefhi')
            let parms = {
              dataGuid: 'e83485a7-0e53-40b9-b881-cf184792be89',
              strParams: JSON.stringify(formData2)
            }
            let paramsendMEssage = {
              accessCode: '77ad6c1591e54d4fbc45ecc90374a2a2',
              cityCode: window.localStorage.getItem('isGJM') == 'true' ? window.localStorage.getItem('citycode') : window.localStorage.getItem('citycodeChange'),
              params: parms
            }
            const res2 = await QuerySignCallback(paramsendMEssage)
            if (ZWJSBridge) {
              ZWJSBridge.openLink({
                url: 'https://zjseal.zjzwfw.gov.cn/api/tyyzpt/sign/doViewDoc?id=' + JSON.parse(res1.data.data).data
              })
                .then((res) => {
                  console.log(res)
                })
                .catch((err) => {
                  window.open('https://zjseal.zjzwfw.gov.cn/api/tyyzpt/sign/doViewDoc?id=' + JSON.parse(res1.data.data).data)
                })
            } else {
              this.$toast.fail(JSON.parse(res1.data.data).errorMsg)
            }
            // }
          }
          window.sessionStorage.setItem('dataf', dataf)
          //不需要判断
          // else {
          // this.$toast.fail("工匠未签订合同!");
          // }
        }
      } else {
        //提示
        this.$toast.fail('请填写合同信息!')
      }
    },
    //下一步
    next: async function () {
      let params = {
        dataGuid: 'b68a5f59-7527-4cb8-bd8a-9b5451bb2d50',
        searchObject: JSON.stringify([
          {
            field: 'row_guid',
            value: JSON.parse(window.localStorage.getItem('rowData')).ROW_GUID,
            link: 'OR',
            operator: '='
          }
        ]),
        token: window.localStorage.getItem('token')
      }
      let params1 = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b',
        cityCode: window.localStorage.getItem('isGJM') == 'true' ? window.localStorage.getItem('citycode') : window.localStorage.getItem('citycodeChange'),
        params: params
      }
      var res = await QuerySignCallback(params1)
      if (eval('(' + res.data.data + ')').Data.length > 0 && eval('(' + res.data.data + ')').Data[0].HTBHQDZT) {
        let params = {
          dataGuid: 'e83485a7-0e53-40b9-b881-cf184792be89',
          searchObject: JSON.stringify([
            {
              field: 'TO_ROW_GUID',
              value: this.rowData.ROW_GUID,
              link: 'OR',
              operator: '='
            }
          ]),
          token: window.localStorage.getItem('token')
        }
        let params1 = {
          accessCode: '688bd3883572440a859dfd8ba9194e7b',

          cityCode: window.localStorage.getItem('isGJM') == 'true' ? window.localStorage.getItem('citycode') : window.localStorage.getItem('citycodeChange'),
          params: params
        }
        var res = await QuerySignCallback(params1)
        if (eval('(' + res.data.data + ')').Data.length > 0) {
          this.$router.push({
            path: '/NextConstructionContract',
            query: {
              rowData: JSON.stringify(this.rowData),
              htRowData: JSON.stringify(eval('(' + res.data.data + ')').Data[0])
            }
          })
        } else {
          //提示
          this.$toast.fail('请填写合同信息!')
        }
      } else {
        this.$toast.fail('农户未签合同!')
      }
    },
    next1: async function () {
      //先调用签完合同的回调函数
      let pdfFileFlag = this.rowData.ROW_GUID
      const res1 = await QuerySignCallback1(pdfFileFlag)
      console.log(res1.data.length == 0, '何志龙')
      //判断是农户还是工匠签完了合同
      let GJISTrue = false
      let NHISTrue = false
      if (res1.data.length != 0) {
        res1.data.forEach((item) => {
          if (item.name == this.rowData.DBRXM || item.name == this.rowData.HOUSEAPPLICANT) {
            NHISTrue = true
          }
          console.log(item.name)
          if (item.name == this.CBRS || item.name == window.sessionStorage.getItem('CBRS')) {
            GJISTrue = true
          } else {
            GJISTrue = true
          }
        })
      }
      if (res1.data.length != 0) {
        if (!this.$store.state.isGJ) {
          if (!GJISTrue) {
            this.$toast.fail('未签字!')
            return
          }
          var formData2 = [
            {
              PKID: JSON.parse(window.localStorage.getItem('rowData')).PKID,
              row_guid: JSON.parse(window.localStorage.getItem('rowData')).ROW_GUID,
              HTQDZT: '1'
              // HTGUID: res1.data[0].fileguid
            }
          ]
        } else if (this.$store.state.isGJ) {
          if (!NHISTrue) {
            this.$toast.fail('未签字!')
            return
          }
          //农户签完
          var formData2 = [
            {
              PKID: JSON.parse(window.localStorage.getItem('rowData')).PKID,
              row_guid: JSON.parse(window.localStorage.getItem('rowData')).ROW_GUID,
              HTBHQDZT: '1',
              F_ISSAVEHT: '1'
              // HTGUID: res1.data[0].fileguid
            }
          ]
        }

        let parms = {
          dataGuid: 'b68a5f59-7527-4cb8-bd8a-9b5451bb2d50',
          strParams: JSON.stringify(formData2)
        }
        let paramsendMEssage = {
          accessCode: '77ad6c1591e54d4fbc45ecc90374a2a2',
          cityCode: window.localStorage.getItem('isGJM') == 'true' ? window.localStorage.getItem('citycode') : window.localStorage.getItem('citycodeChange'),
          params: parms
        }
        const res1 = await QuerySignCallback(paramsendMEssage)
        if (JSON.parse(res1.data.data).Success == true) {
          //需要更新id
          let parmes = {
            contractId: window.sessionStorage.getItem('dataf'), //合同ID
            serialNumber: JSON.parse(window.localStorage.getItem('rowData')).LSH, //统一编号
            rowGuid: JSON.parse(window.localStorage.getItem('rowData')).ROW_GUID, //业务标识
            isOnline: 1 //是否在线签合同
          }
          const res2 = await houseApplyUpdate(parmes)
          if (res2.data.data) {
            this.$toast.success('提交成功!')
            if (JSON.parse(window.sessionStorage.getItem('fileData'))?.S) {
              this.$emit('handleactive2', 2)
              return
            }
            if (this.$route.query.fileData == 1) {
              this.$router.push({
                path: '/TreeSelect',
                query: {
                  data: window.sessionStorage.getItem('fileData'),
                  SJXK: 1
                }
              })
            } else {
              this.$router.push({
                path: '/ZLJIndex'
              })
            }
          }
        }
      } else {
        this.$toast.fail('未签字!')
      }
    }
  },
  async created() {
    try {
      this.rowData = JSON.parse(this.$route.query.data)
    } catch (err) {}
    if (this.SGXKData) {
      this.rowData = this.SGXKData
    }
    if(JSON.parse(window.sessionStorage.getItem('fileData'))?.S){
        this.rowData = JSON.parse(window.sessionStorage.getItem('fileData'))
    }
    console.log(this.rowData, 'dmnfviore')
    window.sessionStorage.setItem('rowData', JSON.stringify(this.rowData))
    if (this.rowData.HTBHQDZT == '1' || this.rowData.HTQDZT == '1' || this.rowData.F_JZQYXMFZR == '1' || this.rowData.F_JZQYSGFZR == '1') {
      this.isreadonly = true
    }
    //1、农户、代办人、建筑企业负责人、项目负责人 都可以收件  2、不管谁上传合同（只有项目负责人和农户、代办人可以上传），其他几个人都可以看到上传的合同，
    //如果是项目负责人上传的合同，需要农户、代办人和施工负责人都同意后才可以给到现场放养申请。如果是农户、代办人上传合同，就需要项目负责人和施工负责人都通同意后才可以到现场放养。
    //3、浙里办建筑企业项目负责人 通过身份证号找到关联的企业，通过企业信用代码查询件，施工负责人通过身分证号查询项目负责人分配的项目
    // const JSONSend = await GJDBFunction2('get_processor_by_rowGuid_and_idCard', [{"i_rowGuid":this.rowData.ROW_GUID,"i_idcard":window.localStorage.getItem("DanDianid")}])
    // console.log(JSONSend,'JSONSend')
  },
  mounted: async function () {
    //先判断是否签订合同
    document.getElementsByTagName('html')[0].style.overflowX = 'visible'
    if (window.localStorage.getItem('isGJM') == 'true') {
      this.$store.state.isGJ = true
    } else {
      this.$store.state.isGJ = false
    }
    console.log(this.$store.state.isGJ)
    let userInfo = window.localStorage.getItem('ISZHUCE')
    window.localStorage.setItem('rowData', JSON.stringify(this.rowData))
    this.getHTXXData()
    let id = ''
    let type = 'view'
    if (!this.$store.state.isGJ) {
      id = 8
      if (this.rowData.F_ISSAVEHT == 1) {
        //已经签过合同，则是编辑状态
        this.iframeUrl = `https://nfzjszlb.jst.zj.gov.cn/webserver/appcs/index.html#/BizForm?userId=${userInfo}&userRole=${id}&rowGuid=${
          this.rowData.ROW_GUID
        }&bg=95c95888-1617-4310-847e-c0a94ec9a923&fd=PKID&ve=${this.rowData.HTGUID}&ft=edit&tk=${window.localStorage.getItem('token')}`
      } else {
        //新增状态
        this.iframeUrl = `https://nfzjszlb.jst.zj.gov.cn/webserver/appcs/index.html#/BizForm?userId=${userInfo}&userRole=${id}&rowGuid=${
          this.rowData.ROW_GUID
        }&bg=95c95888-1617-4310-847e-c0a94ec9a923&fd=PKID&ve=-1&ft=add&tk=${window.localStorage.getItem('token')}`
      }
    } else {
      id = 7
      //已经签过合同，则是编辑状态
      this.iframeUrl = `https://nfzjszlb.jst.zj.gov.cn/webserver/appcs/index.html#/BizForm?userId=${userInfo}&userRole=${id}&rowGuid=${
        this.rowData.ROW_GUID
      }&bg=95c95888-1617-4310-847e-c0a94ec9a923&fd=to_row_GUID&ve=${this.rowData.ROW_GUID}&ft=edit&tk=${window.localStorage.getItem('token')}`
    }
    //判断当前是工匠还是企业签合同的件
    //如果是工匠则隐藏项目负责人和施工负责人
    //如果是企业则展示项目负责人和施工负责人并且请求项目负责人接口
    //需要判断当前是否已经上传过文件
    this.getHTXXData()
    this.getProgectData()
    if (window.localStorage.getItem('userType') == 'QY') {
      this.getUpadateQUE()
    }
    //如果是新流程
    if(this.$store.state.VERSIONNUMBER){
      this.getData1111()
    }
    //根据当前的用户角色更新不同的id
    if (ZWJSBridge) {
      ZWJSBridge.setTitle({
        title: '惠州市低层农村住房建设施工合同'
      })
        .then((res) => {
          console.log(res)
        })
        .catch((err) => {
          console.log(err)
        })
    }
  }
}
</script>
<style lang="scss" scoped>
#ConstructionContract {
  width: 100%;
  height: 100vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  .top1 {
    height: 50px;
    background: #ffffff;
    // margin-bottom: 20px;
    // padding-top: 10px;
    text-align: center;
    font-size: 14px;
  }

  .iframeWrap {
    width: 100%;
    height: calc(100% - 80px);
  }

  .footer {
    display: flex;
    justify-content: space-around;
    margin-top: -10px;
  }

  .top {
    height: 40px;
    background: #ffffff;
    // margin-bottom: 20px;
    padding-top: 25px;
    text-align: center;

    .origin {
      width: 22px;
      height: 22px;
      background: #007aff;
      border-radius: 50%;
      display: inline-block;
    }

    .line {
      width: 20vw;
      /*height: 1px;*/
      border: 1px dashed #007aff;
      display: inline-block;
    }
  }

  .linStyle {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    display: flex;
    color: #646566;
    justify-content: space-between;
    padding: 4px 12px;

    span {
      margin-right: 12px;
    }
  }

  .linStyle1 {
    padding: 20px;
    font-size: 16px;

    .elUp {
      margin-top: 10px;
    }
  }

  .HT_footer {
    display: flex;
    /* height: 201px; */
    /* align-items: center; */
    justify-content: space-around;
    // margin-top: 5%;
  }

  .van-popup {
    border-radius: 10px;

    .con_box {
      width: 270px;
      line-height: 1;
      text-align: center;
      color: #4d5c82;
      padding: 15px;
      box-sizing: border-box;

      > h3 {
        font-size: 20px;
        margin-top: 10px;
        margin-bottom: 20px;
      }

      > p {
        font-size: 17px;
        margin-bottom: 30px;
      }

      .btnv {
        display: flex;
        justify-content: space-between;

        > span {
          display: block;
          width: 114px;
          background-color: #e0e5f5;
          text-align: center;
          line-height: 44px;
          font-size: 17px;
        }

        > span:last-of-type {
          background-color: #1288fe;
          color: #ffffff;
        }
      }
    }
  }
}
</style>

<style lang="scss">
#ConstructionContract .el-upload-list__item:first-child {
  position: absolute;
  margin: 21px -75%;
}

#ConstructionContract .van-field__label {
  // font-size: 16px;
  font-weight: bold !important;
  font-size: 13px !important;
  color: #000 !important;
}

#ConstructionContract .van-field__control {
  text-align: right;
}

#ConstructionContract .van-cell {
  border-bottom: 1px solid rgb(210, 210, 210);
}
#ConstructionContract .van-field__label{
    width: 10em;
}
</style>
